<?php

$a = new VersionableObject();
$a->title = 'Some value';
$a->save();
echo $a->changeLog->getVersion(); // 1
$a->title = 'Some other value';
$a->save();
echo $a->changeLog->getVersion(); // 2

$a->changeLog->revert(1);
echo $a->title; // Some value
echo $a->changeLog->getVersion(); // 1

$a->save();
echo $a->changeLog->getVersion(); // 3

// @orm changeLog [changelog_item_class_name] [include(properties_list)] [exclude(properties_list)]

// on reverting: what happens to files?




$a = new VersionableObject(); // id 2
$b = new ChildObject(); // id 1

$a->children[] = $b;
// 9: added child with id 1
$a->save();

$a->children = array();
$a->save();
// 10: deleted child with id 1

$a->changeLog->revert(10); // argument is log entry id
// on background $a->children[] = ChildObject::load( 1 );



$a->delete();

$otherA = new VersionableObject();
$otherA->changeLog->revive( 1 ); // argument is "revived object id". Loads all latest changes to all properties and sets them to values.
// SELECT
// (SELECT value FROM log WHERE propertyName = 'title' AND className = '' AND objectId = '' ORDER BY version DESC LIMIT 1) as title
// LIMIT 1


//ChangeLog entry properties: id, IP, time, sessionId, version, className, propertyName, objectId, value, action[set,add,remove,delete]

// one to many relation
// 1,,,s1,1,VersionableObject,children,2,1,add
// 2,,,s1,1,ChildObject,parent,1,2,set
// 3,,,s2,2,VersionableObject,children,2,1,remove
// 4,,,s2,2,ChildObject,parent,1,NULL,set

// scalar values
// 5,,,s3,3,VersionavleObject,title,2,New title,set
// 6,,,s4,4,VersionavleObject,title,2,NULL,set

// deleting
// 7,,,s5,3,ChildObject,parent,1,2,remove
// 8,,,s6,4,VersionableObject,NULL,2,NULL,delete

?>